package com.beyond.market.orders.service.impl;

import com.beyond.market.orders.dao.OrdersMapper;
import com.beyond.market.orders.domain.Orders;
import com.beyond.market.orders.service.OrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.sql.SQLException;
import java.util.List;
@Service
public class OrdersServiceImpl implements OrdersService {
    @Autowired(required = false)
    private OrdersMapper ordersMapper;

    @Override
    @Transactional(rollbackFor = SQLException.class)
    public Integer save(Orders orders) throws SQLException {
        return ordersMapper.save(orders);
    }

    @Override
    public Integer delete(Integer id) throws SQLException {
        return ordersMapper.delete(id);
    }

    @Override
    public Integer update(Orders orders) throws SQLException {
        return ordersMapper.update(orders);
    }

    @Override
    public Orders selectById(Integer id) throws SQLException {
        return ordersMapper.selectById(id);
    }

    @Override
    public List<Orders> listByUserId(Integer id) throws SQLException {
        return ordersMapper.listByUserId(id);
    }

    @Override
    public Integer getLastId() throws SQLException {
        return ordersMapper.getLastId();
    }
}
